package com.example.demo.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import com.example.demo.dto.LoginResponseDto;
import com.example.demo.entity.EmployeeEntity;
import com.example.demo.mapper.EmployeeYHLMapper;
import com.example.demo.service.EmployeeYHLService;

@Service
public class EmployeeYHLServiceImpl implements EmployeeYHLService {

	@Resource
	private EmployeeYHLMapper employeeYhlMapper;

	/**
	 * ログイン
	 *
	 * @param requestDto
	 * @return LoginResponseDto
	 */
	public List<LoginResponseDto> login() {

		// 社員情報を取得する
		List<EmployeeEntity> resultList = employeeYhlMapper.loginyhl();
		// The result is empty
		List<LoginResponseDto> loginResponseDtoList = new ArrayList<>();
		if (resultList.isEmpty()) {
			return loginResponseDtoList;
		}

		//The result is not empty
		for (EmployeeEntity employeeEntity : resultList) {
			LoginResponseDto loginResponseDto = new LoginResponseDto();
			BeanUtils.copyProperties(employeeEntity, loginResponseDto);
			loginResponseDto.setProcessingResult("1");
			loginResponseDtoList.add(loginResponseDto);
		}
		return loginResponseDtoList;
	}

}
